package TEST;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        System.out.println("欢迎进入注册系统");
        Scanner input = new Scanner(System.in);
        while (true){
            System.out.println("请输入用户名");
            String user = input.next();
            System.out.println("请输入密码");
            String password1 = input.next();
            System.out.println("请再次输入密码");
            String password2 = input.next();
            if(valLength(user,3) ||valLength(password1,6))
                System.out.println("用户名的长度必须大于3，密码长度不小于6！");

            if (!(valEquals(password1,password2))){
                System.out.println("两次密码不相同");
            }

            if(!valLength(user,3) && !valLength(password1,6)&& (valEquals(password1,password2))){
                System.out.println("注册成功！请牢记用户名和密码。");
                break;
            }
        }

    }

    public static boolean valLength(String string,int length){
        if(string.length()<length){
            return true;
        }
        return false;
    }

    public static boolean valEquals(String s1,String s2){
        if(s1.equals(s2)){
            return true;
        }
        return false;
    }
}
